/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package utn.tsb.tej.world_logic;

import java.io.Serializable;
import csm.uttils.generics.Roster;

/**
 *
 * @author Administrador
 */
public class Card implements Comparable, Serializable {

    protected String name;
    protected CardType type;
    protected boolean awardRecived;

    public boolean isAwardRecived() {
        return awardRecived;
    }

    public void setAwardRecived(boolean awardRecived) {
        this.awardRecived = awardRecived;
    }

    public Card(String name, CardType type) {
        this.name = name;
        this.type = type;
        awardRecived = false;
    }

    public Card() {
        type = new CardType();
        name = "";
        awardRecived = false;
    }

    public CardType getType() {
        return type;
    }

    public void setType(CardType type) {
        this.type = type;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public int compareTo(Object o) {
        Card c = (Card) o;
        int dif = this.name.compareTo(c.getName());
        return dif;
    }

    public void addType(int type) {
        int[] currentTypes = this.type.getTypeValues();
        int[] newTypes;
        if (currentTypes.length == 1 && currentTypes[0] == 0) {
            newTypes = new int[1];
            newTypes[0] = type;
        } else {
            newTypes = new int[currentTypes.length + 1];
            System.arraycopy(currentTypes, 0, newTypes, 0, currentTypes.length);
            newTypes[currentTypes.length] = type;
        }
        try {
            this.type = new CardType(newTypes);
        } catch (Exception ex) {
            System.out.println("no se agrego el tipo" + type);
        }
    }
}
